<?php
class Pageley_Domain_Validator_Number extends Pageley_Domain_Validator_Abstract {
	
	private $notANumberMessage = "error.validation.notANumber";
	
	public function validate($value, $propertyName, $object) {
		$errors = new Pageley_Util_ArrayMap();
		if($value !== null && $value !== "") {
            $notANumber = $this->rejectIfFalse(is_numeric($value), $this->notANumberMessage, array("{field." . $propertyName . "}", $value));
    		if($notANumber) {
    			$errors->put($propertyName, $notANumber);
    		}
        }
		return $errors;
	}
	
	public function setNotANumberMessage($notANumberMessage) {
		$this->notANumberMessage = $notANumberMessage;
	}
}